<%@ page import="java.util.Date" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.BufferedReader" %>
<% 
try {
    Date requestTime = new Date();
    BufferedReader contentsReader = new BufferedReader(
            new InputStreamReader(request.getInputStream()));
    String firstLine = contentsReader.readLine();
    StringBuffer message = new StringBuffer();
    if (firstLine != null) {
        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
        String notificationCode = firstLine.substring(0, 3);
        String notificationMessage = firstLine.substring(4, firstLine.length());
          
        message.append("[");
        message.append(sdf.format(requestTime));
        message.append("] ");
        if ("900".equals(notificationCode)) {
            message.append("Installation notification [");
        } else if ("912".equals(notificationCode)) {
            message.append("Removal notification [");
        } else {
            message.append("Error notification [");
        }
        message.append(notificationMessage);
        message.append("]");
    } else {
    	message.append("Malformed request."); 
    }
    System.out.println(message.toString());
} finally {
      // MIDP Requirement: Independetly of what happens, 
      // 200/OK must be sent as response
      response.setStatus(HttpServletResponse.SC_OK);
      response.flushBuffer();
}
%>